class WeatherCityListModel {
  String? code;
  List<LocationModel>? location;
  Refer? refer;

  WeatherCityListModel({this.code, this.location, this.refer});

  WeatherCityListModel.fromJson(Map<String, dynamic> json) {
    code = json['code'];
    if (json['location'] != null) {
      location = <LocationModel>[];
      json['location'].forEach((v) {
        location!.add(LocationModel.fromJson(v));
      });
    }
    refer = json['refer'] != null ? Refer.fromJson(json['refer']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['code'] = code;
    if (location != null) {
      data['location'] = location!.map((v) => v.toJson()).toList();
    }
    if (refer != null) {
      data['refer'] = refer!.toJson();
    }
    return data;
  }
}

class LocationModel {
  String? name;
  String? id;
  String? lat;
  String? lon;
  String? adm2;
  String? adm1;
  String? country;
  String? tz;
  String? utcOffset;
  String? isDst;
  String? type;
  String? rank;
  String? fxLink;

  LocationModel(
      {this.name,
        this.id,
        this.lat,
        this.lon,
        this.adm2,
        this.adm1,
        this.country,
        this.tz,
        this.utcOffset,
        this.isDst,
        this.type,
        this.rank,
        this.fxLink});

  LocationModel.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    id = json['id'];
    lat = json['lat'];
    lon = json['lon'];
    adm2 = json['adm2'];
    adm1 = json['adm1'];
    country = json['country'];
    tz = json['tz'];
    utcOffset = json['utcOffset'];
    isDst = json['isDst'];
    type = json['type'];
    rank = json['rank'];
    fxLink = json['fxLink'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['name'] = name;
    data['id'] = id;
    data['lat'] = lat;
    data['lon'] = lon;
    data['adm2'] = adm2;
    data['adm1'] = adm1;
    data['country'] = country;
    data['tz'] = tz;
    data['utcOffset'] = utcOffset;
    data['isDst'] = isDst;
    data['type'] = type;
    data['rank'] = rank;
    data['fxLink'] = fxLink;
    return data;
  }
}

class Refer {
  List<String>? sources;
  List<String>? license;

  Refer({this.sources, this.license});

  Refer.fromJson(Map<String, dynamic> json) {
    sources = json['sources'].cast<String>();
    license = json['license'].cast<String>();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['sources'] = sources;
    data['license'] = license;
    return data;
  }
}
